﻿using System;
using System.Collections;
using System.Data;
using System.Reflection;

namespace ZYCommon
{
   

    public class XMLHttpParameterCollection : IDataParameterCollection, IList, ICollection, IEnumerable
    {
        private ArrayList myParams = new ArrayList();

        public int Add(object obj)
        {
            this.myParams.Add(obj);
            return 0;
        }

        public void Clear()
        {
            this.myParams.Clear();
        }

        public bool Contains(string parameterName)
        {
            return (this[parameterName] != null);
        }

        public void CopyTo(Array array, int index)
        {
        }

        public IEnumerator GetEnumerator()
        {
            return this.myParams.GetEnumerator();
        }

        public int IndexOf(string parameterName)
        {
            foreach (XMLHttpParameter parameter in this.myParams)
            {
                if (parameter.ParameterName == parameterName)
                {
                    return this.myParams.IndexOf(parameter);
                }
            }
            return -1;
        }

        public void Insert(int index, object obj)
        {
            this.myParams.Insert(index, obj);
        }

        public void Remove(object obj)
        {
            this.myParams.Remove(obj);
        }

        public void RemoveAt(string parameterName)
        {
            object obj2 = this[parameterName];
            if (obj2 != null)
            {
                this.myParams.Remove(obj2);
            }
        }

        bool IList.Contains(object obj)
        {
            return this.myParams.Contains(obj);
        }

        int IList.IndexOf(object obj)
        {
            return this.myParams.IndexOf(obj);
        }

        void IList.RemoveAt(int index)
        {
            this.myParams.RemoveAt(index);
        }

        public int Count
        {
            get
            {
                return this.myParams.Count;
            }
        }

        public bool IsFixedSize
        {
            get
            {
                return false;
            }
        }

        public bool IsReadOnly
        {
            get
            {
                return false;
            }
        }

        public bool IsSynchronized
        {
            get
            {
                return false;
            }
        }

        public object this[string parameterName]
        {
            get
            {
                foreach (XMLHttpParameter parameter in this.myParams)
                {
                    if (parameter.ParameterName == parameterName)
                    {
                        return parameter;
                    }
                }
                return null;
            }
            set
            {
            }
        }

        public object SyncRoot
        {
            get
            {
                return null;
            }
        }

        object IList.this[int index]
        {
            get
            {
                return this.myParams[index];
            }
            set
            {
                this.myParams[index] = value;
            }
        }
    }
}

